
// 【封装弹框】

// 提示框
export const _toast = ({ title = '数据加载中...', icon = 'none', duration = 2000, mask = true } = {})  => {
  wx.showToast({
    title,
    icon,
    duration,
    mask
  })
}

// 询问框
export const _modal = (options = {}) => {
  const defaultOpt = {
    title: '提示',
    content: '您确定执行该操作吗？',
    confirmColor: '#f3514f',
  }
  const opts = Object.assign({}, defaultOpt, options)
  return new Promise((resolve) => {
    wx.showModal({
      ...opts,
      complete({ confirm, cancel }) {
        confirm && resolve(true)
        cancel && resolve(false)
      }
    })
  })
}
